<template>
  <a-row :gutter="5">
    <a-col :span="4">
      <LeftTree @selected="getTreeData" icon-type="bars" :flag="5"></LeftTree>
    </a-col>
    <a-col :span="20">
      <a-card style="position: relative;overflow-y: auto">
        <div class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :md="6" :sm="8">
                <a-form-item label="事实表述">
                  <a-input placeholder="请输入" v-model="queryParam.wtms"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="8">
                <a-form-item label="定性">
                  <a-input placeholder="请输入" v-model="queryParam.dingxing"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="8">
                <a-form-item label="法律法规">
                  <a-input placeholder="请输入" v-model="queryParam.dxyj"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="8">
                <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                  <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">清除条件</a-button>
                </span>
              </a-col>
            </a-row>
          </a-form>
        </div>

        <!-- 操作按钮区域 -->
        <div class="table-operator">
<!--          <a-button type="primary" style='background-color: #FFA500;border: 0' @click="onDrafView">底稿列表</a-button>-->
          <a-button type="primary" style='background-color: #1A91B3;border: 0' @click="onDownLoad">模板下载</a-button>
          <a-upload v-has="'sjalgl:import'" name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
                    :action="url.importExcelUrl" @change="handleImportExcel"
                    accept=".docx, .doc, .xlsx, .xls, .pdf, .jpeg, .png">
            <a-button type="primary" style='background-color: #1EA489;border: 0'>Excel导入</a-button>
          </a-upload>
        </div>

        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            @change="handleTableChange">
            <span slot="wtms" slot-scope="text">
              <j-ellipsis :value="text" :length="20"/>
            </span>
            <span slot="dxyj" slot-scope="text">
              <j-ellipsis :value="text" :length="10"/>
            </span>
            <span slot="zgjy" slot-scope="text">
              <j-ellipsis :value="text" :length="20"/>
            </span>
            <span slot="actionName">
              <a-button v-has="'sjalgl:add'" size="small" @click="handleAdd('审计案例管理-新增')" type="primary" icon="plus">新增</a-button>
            </span>
            <span slot="action" slot-scope="text, record">
              <a v-has="'sjalgl:detail'" @click="handleCheck(record,'审计案例管理-查看')">查看</a>
              <a-divider v-has="'sjalgl:delete'" type="vertical"/>
              <a-dropdown v-has="'sjalgl:delete'">
                <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
                <a-menu slot="overlay">
                  <a-menu-item v-has="'sjalgl:edit'">
                    <a @click="handleEdit(record,'审计案例管理-编辑')">编辑</a>
                  </a-menu-item>
                  <a-menu-item v-has="'sjalgl:delete'">
                    <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                      <a>删除</a>
                    </a-popconfirm>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
             </span>
          </a-table>
        </div>
        <!-- table区域-end -->
        <CheckAndEditModel ref="modalForm" @ok="modalFormOk"></CheckAndEditModel>
        <DrafView ref="drafView" @ok="modalFormOk"></DrafView>
      </a-card>
    </a-col>
  </a-row>
</template>
<script>
  // 表头
  import LeftTree from '../../components/LeftTree'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import CheckAndEditModel from './CheckAndEditModel'
  import DrafView from './DrafView'
  import JEditor from '@/components/jeecg/JEditor'
  import columns from './indexColumns'

  export default {
    name: '审计案例管理',
    mixins: [JeecgListMixin],
    components: {
      LeftTree,
      CheckAndEditModel,
      JEditor,
      DrafView
    },
    data() {
      return {
        queryParam: {},
        superParam: {
          advType: '1',
          cate: ''
        },
        // 表头
        columns: columns(this),
        url: {
          list: '/sjal/sjWorkZtfaCase/queryAdvanceInfoByWhere',
          delete: '/sjal/sjWorkZtfaCase/delete',
          importExcelUrl: `${window._CONFIG['domianURL']}/sjal/sjWorkZtfaCase/importExcel`
        },
      }
    },
    methods: {
      onDownLoad() {
        this.$message.success('正在下载，请稍等！')
        let url = `${window._CONFIG['domianURL']}/sys/common/static/xls-template/sjal.xlsx`
        window.open(url, '_blank')
      },
      onDrafView() {
        this.$refs.drafView.visible = true
      },
      getTreeData(data) {
        this.superParam.cate = data.id
        this.loadData();
      }
    },
    created() {
    },
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
<style lang="less" scoped>

  .ant-row {
    height: 100%;

    .ant-col {
      height: 100%;

      .ant-card {
        height: 100%;

        /deep/ .ant-card-body {
          padding: 15px;
        }
      }
    }
  }

</style>